import { EastMoney } from './HQData.js';

export const rigOpt = {
  timing: 'easeOut',
  duration: 1000,
  rotate: false,
  rotateLock: false,
  color: [
    '#F46062',
    '#ff5d22',
    '#ff7124',
    '#2c866a',
    '#4dad7f',
    '#7EE18A',
    '#FC8452',
    '#9A60B4',
    '#ea7ccc',
  ],
  padding: [5, 5, 5, 5],
  fontSize: 13,
  fontColor: '#666666',
  dataLabel: true,
  dataPointShape: true,
  dataPointShapeType: 'solid',
  touchMoveLimit: 60,
  enableScroll: false,
  enableMarkLine: false,
  legend: {
    show: false,
    position: 'bottom',
    lineHeight: 25,
    float: 'center',
    padding: 5,
    margin: 5,
    backgroundColor: 'rgba(0,0,0,0)',
    borderColor: 'rgba(0,0,0,0)',
    borderWidth: 0,
    fontSize: 12,
    fontColor: '#666666',
    hiddenColor: '#CECECE',
    itemGap: 10,
  },
  title: {
    name: '今日资金',
    fontSize: 15,
    color: '#666666',
    offsetX: 0,
    offsetY: 0,
  },
  subtitle: {
    show: false,
    name: '',
    fontSize: 25,
    color: '#7cb5ec',
    offsetX: 0,
    offsetY: 0,
  },
  extra: {
    ring: {
      ringWidth: 20,
      activeOpacity: 0.5,
      activeRadius: 10,
      offsetAngle: -90,
      labelWidth: 15,
      border: false,
      borderWidth: 3,
      borderColor: '#FFFFFF',
      centerColor: '#FFFFFF',
      customRadius: 0,
      linearType: 'none',
    },
    tooltip: {
      showBox: true,
      showArrow: true,
      showCategory: false,
      borderWidth: 0,
      borderRadius: 0,
      borderColor: '#000000',
      borderOpacity: 0.7,
      bgColor: '#000000',
      bgOpacity: 0.7,
      gridType: 'solid',
      dashLength: 4,
      gridColor: '#CCCCCC',
      boxPadding: 3,
      fontSize: 13,
      lineHeight: 20,
      fontColor: '#FFFFFF',
      legendShow: true,
      legendShape: 'auto',
      splitLine: true,
      horizentalLine: false,
      xAxisLabel: false,
      yAxisLabel: false,
      labelBgColor: '#FFFFFF',
      labelBgOpacity: 0.7,
      labelFontColor: '#666666',
    },
  },
};

export const columOpt = {
  color: [
    '#1890FF',
    '#91CB74',
    '#FAC858',
    '#EE6666',
    '#73C0DE',
    '#3CA272',
    '#FC8452',
    '#9A60B4',
    '#ea7ccc',
  ],
  padding: [15, 15, 0, 5],
  enableScroll: false,
  legend: {
    show: false,
  },
  xAxis: {
    disableGrid: true,
    marginTop: 20,
  },
  yAxis: {
    disabled: true,
    // disableGrid:true,
    data: [
      {
        min: -80,
        max: 80,
      },
    ],
    splitNumber: 4,
  },
  extra: {
    column: {
      type: 'group',
      width: 30,
      activeBgColor: '#000000',
      activeBgOpacity: 0.08,
    },
  },
};

export const DefaultData = function () {};
DefaultData.GetKLineDayPeriodMenu = function () {
  var data = [
    {
      Name: '日线',
      ID: 0,
    },
    {
      Name: '周线',
      ID: 1,
    },
    {
      Name: '月线',
      ID: 2,
    },
  ];
  return data;
};
DefaultData.GetKLineOption = function () {
  var option = {
    Type: '历史K线图', //创建图形类型

    //窗口指标
    Windows: [
      {
        Index: 'MA',
      },
      {
        Index: 'VOL',
      },
    ],
    Symbol: '000001.sh',
    IsAutoUpdate: true, //是自动更新数据
    AutoUpdateFrequency: 15000,
    IsApiPeriod: true,
    IsShowRightMenu: false, //是否显示右键菜单
    IsFullDraw: true, //不是使用缓存每次都重绘
    CorssCursorTouchEnd: true,
    IsClickShowCorssCursor: true,
    KLine: {
      DragMode: 1, //拖拽模式 0 禁止拖拽 1 数据拖拽 2 区间选择
      Right: 0, //复权 0 不复权 1 前复权 2 后复权
      Period: 0, //周期 0 日线 1 周线 2 月线 3 年线
      MaxReqeustDataCount: 1000, //数据个数
      PageSize: 15, //一屏显示多少数据
      KLineDoubleClick: false, //双击分钟走势图
      IsShowTooltip: false, //是否显示K线提示信息
      DrawType: 0,
      RightSpaceCount: 1,
    },

    CorssCursorInfo: {
      Left: 0,
      Right: 1,
    },

    //标题设置
    KLineTitle: {
      IsShowName: false, //不显示股票名称
      IsShowSettingInfo: false, //不显示周期/复权
    },

    //边框
    Border: {
      Left: 2, //左边间距
      Right: 2, //右边间距
      Top: 25,
      Bottom: 25,
      AutoLeft: {
        Blank: 10,
        MinWidth: 40,
      },
    },

    //子框架设置
    Frame: [
      {
        SplitCount: 5,
        IsShowLeftText: false,
      },
      {
        SplitCount: 3,
        IsShowLeftText: false,
      },
      {
        SplitCount: 3,
        IsShowLeftText: false,
      },
    ],

    //扩展图形
    ExtendChart: [
      {
        Name: 'KLineTooltip',
      }, //手机端tooltip
    ],
  };

  return option;
};
DefaultData.GetMinuteOption = function () {
  var option = {
    Type: '分钟走势图', //创建图形类型

    //窗口指标
    Windows: [],

    IsAutoUpdate: true, //是自动更新数据
    DayCount: 1, //1 最新交易日数据 >1 多日走势图
    IsShowRightMenu: false, //是否显示右键菜单
    CorssCursorTouchEnd: true,
    OverlayIndex: [
      {
        Index: 'MACD',
        Windows: 1,
      },
    ],
    MinuteLine: {
      //IsDrawAreaPrice:false,      //是否画价格面积图
    },

    //边框
    Border: {
      Left: 1, //左边间距
      Right: 1, //右边间距
      Top: 20,
      Bottom: 20,
    },

    //子框架设置
    Frame: [
      {
        SplitCount: 3,
        StringFormat: 0,
      },
      {
        SplitCount: 2,
        StringFormat: 0,
      },
      {
        SplitCount: 3,
        StringFormat: 0,
      },
    ],

    //扩展图形
    ExtendChart: [
      {
        Name: 'MinuteTooltip',
      }, //手机端tooltip
    ],
  };

  return option;
};

// export const NetworkFilter=(data,callback)=>{
// 		console.log('[NetworkFilter] data', data);
// 		data.PreventDefault=true;
// 		uni.request({
// 			url:'/API'+data.Request.Url.split('/API')[1],
// 			method:data.Request.Type,
// 			data:data.Request.Data,
// 			success: (res) => {
// 				callback(res.data)
// 			}
// 		})
// }

export const NetworkFilter = (data, callback) => {
  console.log('[NetworkFilter] data', data);
  switch (data.Name) {
    //分时图数据对接
    case 'MinuteChartContainer::RequestMinuteData':
      EastMoney.HQData.NetworkFilter(data, callback);
      break;
    case 'MinuteChartContainer::RequestHistoryMinuteData':
      EastMoney.HQData.NetworkFilter(data, callback);
      break;

    case 'KLineChartContainer::RequestHistoryData': //日线全量数据下载
      EastMoney.HQData.NetworkFilter(data, callback);
      break;
    case 'KLineChartContainer::RequestRealtimeData': //日线实时数据更新
      EastMoney.HQData.NetworkFilter(data, callback);
      break;
    case 'KLineChartContainer::RequestFlowCapitalData': //流通股本
      EastMoney.HQData.NetworkFilter(data, callback);
      break;
    case 'KLineChartContainer::ReqeustHistoryMinuteData': //分钟全量数据下载
      EastMoney.HQData.NetworkFilter(data, callback);
      break;
    case 'KLineChartContainer::RequestMinuteRealtimeData': //分钟增量数据更新
      EastMoney.HQData.NetworkFilter(data, callback);
      break;

    case 'JSSymbolData::GetSymbolData': //无图形指标计算
      EastMoney.HQData.NetworkFilter(data, callback);
      break;
  }
};
